package com.macro.mall.portal.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

@Component
public class EndpointPrinter implements CommandLineRunner {

    @Autowired
    @Qualifier("requestMappingHandlerMapping")
    private RequestMappingHandlerMapping handlerMapping;

    @Override
    public void run(String... args) throws Exception {
        System.out.println("========= 所有已注册的请求路径 =========");
        handlerMapping.getHandlerMethods().forEach((mapping, method) -> {
            System.out.println(mapping + " => " + method);
        });
        System.out.println("=====================================");
    }
}
